# coding=utf-8
# @Time: 2023/2/15 1:06
# @Author: zyg
# email: zhaoyiguang@lecent.cn
from time import sleep

import allure


def add_img_2_report(driver, step_name, need_sleep=True):
    """
    截图并插入allure报告
    :param driver: 浏览器驱动
    :param step_name: 步骤名称
    :param need_sleep: 需要休眠时间 默认为True，需要休眠；为False不需要休眠
    :return:
    """
    if need_sleep:
        sleep(1)
    allure.attach(
        driver.get_screenshot_as_png(),
        step_name + ".png",
        allure.attachment_type.PNG
    )

def add_img_path_2_report(img_path, step_name):
    """
    将图片插入Allure报告
    :param img_path: 图片路径
    :param step_name: 步骤名称
    :return:
    """
    allure.attach.file(img_path, step_name, allure.attachment_type.PNG)
